const express = require('express');
const router = express.Router();
const environmentController = require('../controllers/environmentController');
const authMiddleware = require('../middleware/authMiddleware');

// 获取当前室内环境数据
router.get('/current', environmentController.getCurrentIndoorEnvironment);

// 获取室内环境历史数据
router.get('/history', environmentController.getIndoorEnvironmentHistory);

// 获取环境舒适度评估
router.get('/assessment', environmentController.getEnvironmentAssessment);

// 获取环境趋势预测
router.get('/prediction', environmentController.getEnvironmentPrediction);

// 添加新的环境数据记录（需要认证，通常由传感器或管理员调用）
router.post('/record', authMiddleware.authenticateToken, environmentController.addEnvironmentRecord);

// 获取特定时间范围的环境数据
router.get('/range', environmentController.getEnvironmentDataByRange);

// 获取环境数据统计信息
router.get('/statistics', environmentController.getEnvironmentStatistics);

// 获取特定设备的当前环境数据
router.get('/device/:deviceId/current', environmentController.getDeviceEnvironmentData);

// 获取特定设备的环境历史数据
router.get('/device/:deviceId/history', environmentController.getDeviceEnvironmentHistory);

module.exports = router;